//
//  IManager+ModuleAddMerchant.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-10-1.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+ModuleAddMerchant.h"
#import "FrameworkRelativeDefines.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "NSString+NSString_Ex_.h"
#import "TravelException.h"
#import "GloableEngineService.h"
#import "RCFeedbackDataModel.h"

#define POST_BOBY_DATA_DATA @"postBobyData"
#define POST_BOBY_DATA_KEY  @"postBobyDataKey"
#define POST_BOBY_DATA_FILE_NAME  @"postBobyDataFileName"
#define POST_BOBY_DATA_CONTENT_TYPE  @"postBobyDataContentType"

@implementation IManager(ModuleAddMerchant)

-(int64_t)requestAddMerchantWithInfo:(NSMutableDictionary *)dict withDelegate:(id<IManagerDelegate>)delegate{
    if (nil == dict) {
        return kInvalidRequestId;
    }
    NSString *urlSuffix = kRCMerchantAddPrefix;
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    
    NSString *bduss = [GloableEngineService sharedInstance].bduss;
    [dict setObject:bduss forKey:@"bduss"];
    
    NSData *data = [dict objectForKey:@"uploadfile"];
    
    NSMutableArray *imgDataList = nil;
    if (data != nil) {
        imgDataList = [[[NSMutableArray alloc] initWithCapacity:1] autorelease];
        NSMutableDictionary *t = [[NSMutableDictionary alloc] init];
        [t setObject:data  forKey:POST_BOBY_DATA_DATA];
        [t setObject:@"image/jpeg"  forKey:POST_BOBY_DATA_CONTENT_TYPE];
        [t setObject:@"uploadfile"  forKey:POST_BOBY_DATA_KEY];
        [t setObject:@"myphoto.jpg"  forKey:POST_BOBY_DATA_FILE_NAME];
        [imgDataList addObject:t];
        [t release];
        [dict removeObjectForKey:@"uploadfile"];
    }
    
    return [[IDataProvider sharedInstance] asyncPostData:url postValues:dict postDataList:imgDataList userInfo:nil withDataParseClass:[RCFeedbackDataModel class] withDataDelegate:delegate];
}

@end
